#ifndef INPUT_H
#define INPUT_H

#define INPUT_STEP_FOWARD             0.4
#define INPUT_STEP_RIGHT              0.4
#define INPUT_ROTATION_ANGLE_RIGHT    7
#define INPUT_ROTATION_ANGLE_UP       7
#define WINDOW_LEFT_MARGIN            13
#define WINDOW_TOP_MARGIN             97

class Input
{
private:

	float rightRotation;
	float upRotation;

	float moveFoward;
	float moveRight;

public:

    int centerW;
    int centerH;

    bool mouseIsEnabled;
	int mouseX;
	int mouseY;
    int prevMouseX;
	int prevMouseY;
	bool mouseLeftButtonOn;
	bool mouseRightButtonOn;
	bool mouseMiddleButtonOn;
	bool mouseIsDragging;
    bool mouseWasCentered;

    Input()
	{
		moveFoward = 0;
		moveRight  = 0;

        mouseIsEnabled = true;

		mouseX = 0;
		mouseY = 0;
		mouseLeftButtonOn   = false;
		mouseRightButtonOn  = false;
		mouseMiddleButtonOn = false;
		mouseIsDragging     = false;
        mouseWasCentered    = false;

		rightRotation = 0;
		upRotation = 0;
	}

	void stepBackward(bool val)
	{
		if (val)
		{
			if (moveFoward < 0)
				moveFoward = 0;
			else
				moveFoward = INPUT_STEP_FOWARD;
		}
		else
			stepFoward(true);
	}

    void centerMouseCoords()
    {
        mouseWasCentered = true;
        SetCursorPos(centerX, centerY);
    }

	void stepFoward(bool val)
	{
		if (val)
		{
			if (moveFoward > 0)
				moveFoward = 0;
			else
				moveFoward = -INPUT_STEP_FOWARD;
		}
		else
			stepBackward(true);
	}

	void stepLeft(bool val)
	{
		if (val)
		{
			if (moveRight > 0)
				moveRight = 0;
			else
				moveRight = -INPUT_STEP_RIGHT;
		}
		else
			stepRight(true);
	}

	void stepRight(bool val)
	{
		if (val)
		{
			if (moveRight < 0)
				moveRight = 0;
			else
				moveRight = INPUT_STEP_RIGHT;
		}
		else
			stepLeft(true);
	}


	void rotateDown(bool val)
	{
		if (val == true)
		{
			if (upRotation < 0)
				upRotation = 0;
			else
				upRotation = 1;
		}
		else
			rotateUp(true);
	}

	void rotateUp(bool val)
	{
		if (val == true)
		{
			if (upRotation > 0)
				upRotation = 0;
			else
				upRotation = -1;
		}
		else
			rotateDown(true);
	}

	void rotateRight(bool val)
	{
		if (val)
		{
			if (rightRotation < 0)
				rightRotation = 0;
			else
				rightRotation = 1;
		}
		else
			rotateLeft(true);
	}

	void rotateLeft(bool val)
	{
		if (val)
		{
			if (rightRotation > 0)
				rightRotation = 0;
			else
				rightRotation = -1;
		}
		else
			rotateRight(true);
	}
	float getStepRight()
	{
		return moveRight;
	}
	float getStepFoward()
	{
		return moveFoward;
	}
	float getUpRotation()
	{
		return upRotation;
	}

	float getRightRotation()
	{
		return rightRotation;
	}
};

#endif